package com.briup.day14;

/**
 * @author ThinkBook
 */
public class Test04_Integer {
    public static void main(String[] args) {
        //int 和 Integer
        Integer i = 10;
        int num = i;

        //double <-> Double
        double d = 10.4;
        Double dd = d;
        double d2 = dd;

        //注意: 自动装箱时候 要保证类型一致
        //Long l = 2; ERROR
        Long l2 = 23L;
        //int t = l2; ERROR
        long t = l2;

        //给Byte Short Character赋值时，需要考虑 常量优化机制
        Byte b1 = 2;
        Byte b2 = 127;
        //Byte b3 = 128;  ERROR

        Character c1 = 3;
        Character c2 = '\u0989';
        Character c3 = 65535;
        //Character c4 = 65536;   ERROR
    }
    //对int的包装类integer进行测试
    public static void main01(String[] args) {
//        Integer i = new Integer(1);
//        System.out.println("int最大取值：" + );
//        System.out.println("int最小取值：" + );

            System.out.println("byte最大值: " + Byte.MAX_VALUE);
            System.out.println("byte最小值: " + Byte.MIN_VALUE);

            String str = Integer.toHexString(103);
            System.out.println("103的16进制: " + str);
            System.out.println("103的8进制: " + Integer.toOctalString(103));
            System.out.println("103的2进制: " + Integer.toBinaryString(103));

            System.out.println("-------------");

            //将字符串(10进制) 转换成 整型数
            str = "134";
            int num = Integer.parseInt(str);
            System.out.println("num: " + num);

            str = "0010111";
            //parseInt需要掌握
            num = Integer.parseInt(str,2);
            System.out.println("num: " + num);

        }
}
